import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index')
  },
  {
    path: '/',
    // name: 'layout',
    component: () => import('@/views/layout/index'),
    children: [{ path: '', redirect: 'home' }, {
      path: 'home',
      name: 'home',
      component: () => import('@/views/home/index')
    }, {
      path: 'qa',
      name: 'qa',
      component: () => import('@/views/qa/index')
    }, {
      path: 'video',
      name: 'video',
      component: () => import('@/views/video/index')
    }, {
      path: 'my',
      name: 'my',
      component: () => import('@/views/my/index')
    }]
  }, {
    path: '/search',
    name: 'search',
    component: () => import('@/views/search/index')
  }, {
    path: '/article/:articleId', // 动态路由
    name: 'article',
    component: () => import('@/views/article/index'),
    props: true// 一步开启路由传参articleId
  }, {
    path: '/user/profile',
    name: 'user-profile',
    component: () => import('@/views/user-profile/index')
  }
]

const router = createRouter({
  history: createWebHashHistory(), // 创建浏览历史
  routes
})

export default router
